package com.tongcheng.service.impl;

import com.tongcheng.mapper.ActivityMapper;
import com.tongcheng.mapper.CouponsMapper;
import com.tongcheng.pojo.Coupons;
import com.tongcheng.pojo.Coupons_use_rules;
import com.tongcheng.service.Couponssevice;
import com.tongcheng.utils.ConversionDateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@Service
public class Couponsseviceimpl implements Couponssevice {

    @Autowired(required = false)
    private CouponsMapper couponsMapper;

    @Override
    public int addCoupons(Map map) {
              return couponsMapper.addCoupons(map);
    }
    @Override
    public int addCoupons_use_rules(Map map) {
             return couponsMapper.addCoupons_use_rules(map);
    }
    @Override
    public List<Map> queryCouponsByuserid(Integer userId) {
        List<Map> mapList=couponsMapper.queryCouponsByuserid(userId);
        for (Map  map:mapList) {
           map.put("coupons_create_time", ConversionDateUtils.conversionDateStringUtils(map.get("coupons_create_time")));
           map.put("start_time",ConversionDateUtils.conversionDateStringUtils(map.get("start_time")));
           map.put("end_time",ConversionDateUtils.conversionDateStringUtils(map.get("end_time")));
        }
        return mapList;
    }

    @Override
    public int delCoupons(Integer coupons_id) {
        return couponsMapper.delCoupons(coupons_id);
    }

    @Override
    public List<Map> queryCoupons(Integer activity_id) {
        return couponsMapper.queryCoupons(activity_id);
    }



    @Override
    public int userReceiveCoupons(Integer userId, Integer coupons_id) {
        return couponsMapper.userReceiveCoupons(userId,coupons_id);
    }

    @Override
    public List<Map> userSeeCoupons(Integer userId) {
        return couponsMapper.userSeeCoupons(userId);
    }

    @Override
    public List<Map> userCouponsQeury(Integer userId) {

        return couponsMapper.userCouponsQeury(userId);
    }

    @Override
    public List<Map> merchantSeeCoupons(Long merchant_id) {
        return couponsMapper.merchantSeeCoupons(merchant_id);
    }

    @Override
    public List<Map> merchantCouponsQeury(Long merchant_id) {
        return couponsMapper.merchantCouponsQeury(merchant_id);
    }

    @Override
    public int merchantReceiveCoupons(Long merchant_id, Integer coupons_id) {
        return couponsMapper.merchantReceiveCoupons(merchant_id,coupons_id);
    }
}
